import axios from '../utils/axios';

const token = localStorage.getItem('token')

export const getJobByPage = async (params) => {

    let response = {}
    await axios.get('/api/job/query', {
        headers: {
            Authorization: token
        }
    })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}

export const createJob = async (data) => {
    let response = {}
    await axios.post('/api/job', data, { headers: { Authorization: token }, })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}


export const updateJob = async (data) => {
    let response = {}
    await axios.put('/api/job', data, { headers: { Authorization: token }, })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}

export const deleteJob = async (params) => {
    let response = {}
    await axios.request({
        url: `/api/job`,
        method: 'delete',
        data: params,
        headers: { Authorization: token }
    })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })
    return response
}